<!DOCTYPE html>
<html>
<head>
	<title>object</title>
	<meta charset="utf-8">
	<script type="text/javascript">
	/*
		var message="Hello World!";
		console.log(message.length);
		console.log(message.toUpperCase());
		
		var object1 = {  // 创建对象的方式一，字面量创建对象


		};
	
		
		var document1 = new Object();  //定义并创建对象的实例
		document1.head = new Object();
		document1.body = new Object();

		document1.head.title = new Object;

		document1.body.a = new Object();

		document1.body.h1 = new Object();

		document1.body.a.style = new Object();

		document1.body.a.id = "123";  // 这个时候id是字符串，但是它是关联到 docuemnt1.body.a 的字符串

		var tempid = document1.body.a.id;
		
		tempid = "asd";

		 console.log(document1.body.a.id);  // 不会影响到 document1.body.a.id

		var tempa = document1.body.a;

		tempa.id = "asd";

		


		 console.log(document1.body.a.id); // 会影响到 document1.body.a.id

		 tempaa = tempa;
		 tempaa.id = "aaaaa";

		 console.log(document1.body.a.id);


		注意特殊的是string number 这些基本类型对象比较特殊
	*/

		

	/*
	
		//this 代表什么？？？？？，this指向该函数所属的对象（运行时）
		function person(firstname,lastname,age,eyecolor){
			this.firstname=firstname;// window.firstname
			this.lastname=lastname;
			this.age=age;
		    this.eyecolor=eyecolor;
		    // alert(this);
		   

		}

		// 任何全局变量或者函数其实是属于window下面的属性或者方法
		// console.log(person);
		// console.log(typeof person);
		// console.log(person === window.person); // this = window
		
		// person("ouyang","ri",123,"black");
		// console.log(firstname);


		// 这个时候 obj1 是一个 person 对象
		var obj1 = new person("aa","bb",21,"black");
		// obj1.changeName("cccc");
		console.log(obj1.lastname);
		console.log(obj1.firstname);

	*/


	/*
			var number1 = 123;
			var objnumber = new Number(123); 


			console.log(number1);
			console.log(objnumber);

			console.log(typeof number1);
			console.log(typeof objnumber);

			console.log(typeof number1.toString());  //临时 number1 = new Number(123);  结束之后就销毁这个对象
			console.log(typeof objnumber.toString());

			var number2 = number1;
			number2 = 345;

			var objnumber2 = objnumber;
			objnumber = 345;

			console.log(number1);
			console.log(objnumber);
		*/	
	
		
	/*
		var str = "ouyang";
		var objstr = new String("aaabbb");

		var str2 = str;
		str2 = "12345";

		var objstr2 = objstr;
		objstr2 = "bbccc";

		console.log(str);
		console.log(objstr);


		console.log(str.length);    //临时 str = new String(ouyang);  结束之后就销毁这个对象
		objstr.aa = "bbb"
		console.log(objstr.length);
		
	*/

		

	</script>
</head>
<body>
<!--
	<h1 id="h1" class="aa">DOM Lesson <span>one</span></h1>
 
	<div id="div1">
		<p id="p1">This is a paragraph.</p>
		<p id="p2">This is another paragraph.</p>
	</div>

    <script type="text/javascript">
    
    	var h1 = document.getElementById("h1");
  
    	
		console.log(h1.innerHTML );
		console.log(h1.nodeName );
		console.log(h1.attributes);
		console.log(h1.attributes[0].nodeName);
		console.log(h1.attributes[0].nodeValue);
		console.log(h1.nodeType);
		console.log(h1.attributes[0].nodeType);
		console.log(h1.parentNode);
		

		// console.log(h1.getAttribute("class"));
		// h1.setAttribute("class","bb");
		// h1.setAttribute("index","0");


		var para=document.createElement("p");
		// var text=document.createTextNode("This is a new paragraph."); 
		// para.appendChild(text);
		para.innerHTML = "This is a new paragraph.";
		// h1.appendChild(para);


		// var para=document.createElement("a");
		// var text=document.createTextNode("aaaa"); 
		// para.appendChild(text);
		// h1.in(para);
	
    </script>

    -->

    <!--
	    <div id="div1">
			<p id="p1">This is a paragraph.</p>
			<p id="p2">This is another paragraph.</p>
		</div>
		<script>
			// var parent=document.getElementById("div1");
			var child=document.getElementById("p2");
			// parent.removeChild(child);
			child.parentNode.removeChild(child);
		</script>
	-->

<!-- 
	<div id="div1">
		<p id="p1">This is a paragraph.</p>
		<p id="p2">This is another paragraph.</p>
	</div>

	<script>
		var para=document.createElement("p");
		var node=document.createTextNode("This is new.");
		para.appendChild(node);

		var parent=document.getElementById("div1");
		var child=document.getElementById("p1");
		parent.replaceChild(para,child);
	</script> -->


<!-- 	<script type="text/javascript">
		
		console.log(document.documentElement);
		console.log(document.body);
		console.log(document);
	</script>
 -->

 	<!-- <ul id="ul">111
 		<li>aaa</li>222
 		<li>bbb</li>333
 		<li>ccc</li>444
 	</ul>
 	<script type="text/javascript">
 		var ul=document.getElementById("ul");
 		console.log(ul.childNodes);
 		for(var i = 0;i < ul.childNodes.length;i++){
 			if(ul.childNodes[i].nodeType == 3){
 				console.log(ul.childNodes[i].nodeValue);
 			}
 		}
 	</script> -->
</body>
</html>